package com.example.controller.userorder;

import com.example.pojo.Product;
import com.example.pojo.Userorder;
import com.example.pojo.intermediate.OrderreturnSc;
import com.example.service.userorder.UserOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
/**
 * 功能描述: <br>
 * 〈〉订单操作
 * @Author: 10260
 * @Date: 2022/11/20 14:41
 */
@Slf4j
@Controller
@RequestMapping("userorder")
@ResponseBody
public class UserOrderController {
    @Autowired
    private UserOrderService userOrderService;
    /**
     * 功能描述: <br>
     * 〈〉全查订单   模糊查询    根据订单状态查询
     * @Param: [userorder]
     * @Return: java.util.List<com.example.pojo.Userorder>
     * @Author: 10260
     * @Date: 2022/11/12 14:02
     */
    @RequestMapping("getAll")
    private List<Userorder> getAll(Userorder userorder){
        if(userorder.getCreateDate() != null){
            java.sql.Date date = new Date(userorder.getCreateDate().getTime());
            userorder.setCreateDate(date);
            System.out.println(userorder.getCreateDate());
        }

        log.info("订单查询操作，userorder:{userorder}");
        return userOrderService.userorderall(userorder);
    }
    /**
     * 功能描述: <br>
     * 〈〉查看订单对应商品信息
     * @Param: [id]
     * @Return: com.example.pojo.Product
     * @Author: 10260
     * @Date: 2022/11/12 14:02
     */
    @RequestMapping("getBysp")
    private Product getBysp(Integer id){
        return userOrderService.getBysp(id);
    }

    /**
     * 功能描述: <br>
     * 〈〉商品退货列表全查    及条件查讯
     * @Param: [orderreturnSc]
     * @Return: java.util.List<com.example.pojo.intermediate.OrderreturnSc>
     * @Author: 10260
     * @Date: 2022/12/6 19:15
     */
    @RequestMapping("getOrderrenturnScAll")
    private List<OrderreturnSc> getOrderrenturnScAll(OrderreturnSc orderreturnSc){
        List<OrderreturnSc> orderrenturnScAll = userOrderService.getOrderrenturnScAll(orderreturnSc);
        return orderrenturnScAll;
    }
}
